# -- coding: utf-8 --
import unittest
from calc import Cal


class TestCal1(unittest.TestCase):
    # def setUp(self):    #数据准备, 或者环境准备
    #     print('start')
    @classmethod
    def setUpClass(cls):
        print('start')

    def testcase01(self):  # 测试用例的方法必须以test开头
        result = Cal().add(1, 2)
        self.assertEqual(result, 3, '用例执行失败.')

    def testcase02(self):
        result = Cal().add(1, 2)
        self.assertEqual(result, 5, '用例执行失败.')

    # def tearDown(self):     #清理数据, 还原测试环境
    #     print('end')
    @classmethod
    def tearDownClass(cls):
        print('end')


# class TestCal2(unittestdemo.TestCase):
#     def setUp(self):    #数据准备, 或者环境准备
#         pass
#
#     def testcase01(self):   #测试用例的方法必须以test开头
#         result = Cal().add(a.txt,2)
#         self.assertEqual(result, 3, '用例执行失败.')
#
#     def testcase02(self):
#         result = Cal().add(a.txt, 2)
#         self.assertEqual(result, 5, '用例执行失败.')
#
#     def tearDown(self):     #清理数据, 还原测试环境
#         pass

if __name__ == '__main__':
    # unittestdemo.main()
    suite = unittest.TestSuite()  # 实例化测试集
    # testcases = unittestdemo.TestLoader().loadTestsFromTestCase(TestCal1) #通过类名来构建测试用例
    # suite.addTest(testcases)

    testcases1 = unittest.TestLoader().loadTestsFromTestCase(TestCal1)  # 通过类名来构建测试用例
    # testcases2 = unittestdemo.TestLoader().loadTestsFromTestCase(TestCal2)
    suite.addTests(tests=(testcases1,))

    runner = unittest.TextTestRunner(verbosity=2)  #
    runner.run(suite)
